package com.jumi.microservice.controller;

import com.jumi.microservice.common.base.BaseController;
import com.jumi.microservice.common.base.dto.ResponseResult;
import com.jumi.microservice.common.page.TableDataInfo;

import com.jumi.microservice.dto.ceshi.CeshiApiAddRequest;
import com.jumi.microservice.dto.ceshi.CeshiApiListRequest;
import com.jumi.microservice.dto.ceshi.CeshiApiListResponse;
//import com.jumi.microservice.dto.usercash.UserCashOperateRequest;
import com.jumi.microservice.dto.usercash.api.UserCashApiAddRequest;
import com.jumi.microservice.dto.usercash.api.UserCashApiDetailRequest;
import com.jumi.microservice.dto.usercash.api.UserCashApiDetailResponse;
import com.jumi.microservice.service.CeshiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = {"我的测试相关接口"})
@RestController
@RequestMapping("/ceshi")
public class Ceshicontroller extends BaseController {
    @Resource
    private CeshiService ceshiService;

    @GetMapping("/ceshilist")
    @ApiOperation("列表")
    TableDataInfo<CeshiApiListResponse> ceshiApiList(CeshiApiListRequest ceshiApiListRequest) {
        //获取当前用户ID
        //userCashApiListRequest.setUid(ThreadLocalTools.getUid());
        //ceshiApiListRequest.setUid(10119L);//ceshiApiListRequest 需要传递的值
        //ceshiApiListRequest.setTitle("于谦");
        return ceshiService.ceshiList(ceshiApiListRequest);
    }

    @GetMapping("/ceshidetail") //查询
    @ApiOperation("详情")
    public ResponseResult<CeshiApiListResponse> ceshiApiDetail(CeshiApiListRequest ceshiApiListRequest) {
        ResponseResult<CeshiApiListResponse> result = new ResponseResult<>();
        //获取当前用户ID
        //userCashApiDetailRequest.setUid(ThreadLocalTools.getUid());
        ceshiApiListRequest.setId(6);
        CeshiApiListResponse ceshiApiListResponse = ceshiService.ceshiDetail(ceshiApiListRequest);
        result.setData(ceshiApiListResponse);
        return result;
    }

    @PostMapping("/ceshiadd")//添加
    @ApiOperation("tianjia")
    public ResponseResult<Boolean> addCeshi(CeshiApiAddRequest ceshiApiAddRequest) {
        ResponseResult<Boolean> result = new ResponseResult<>();
        //获取当前用户ID
        //userCashApiAddRequest.setUid(ThreadLocalTools.getUid());
        //ceshiApiAddRequest.setUid(10119L);
       /* ceshiApiAddRequest.setTitle("重生");
        ceshiApiAddRequest.setName("虎爪");
        ceshiApiAddRequest.setAge(33);*/
        result.setData(ceshiService.addCeshi(ceshiApiAddRequest));
        return result;
    }

    @PutMapping("/editceshi")
    @ApiOperation("xiugai")
    public ResponseResult<Boolean> editCeshi(CeshiApiAddRequest ceshiApiAddRequest) {
        ResponseResult<Boolean> result = new ResponseResult<>();
        result.setData(ceshiService.editCeshi(ceshiApiAddRequest));
        return result;
    }

    @PostMapping("/fapiao")//添加
    @ApiOperation("fapiao")
    public String faPiao() {
        ResponseResult result = new ResponseResult<>();
        return ceshiService.faPiao();
    }



}
